<template>
  <div class="goods-hot">
    <h3 v-if="type === 1">24小时热榜</h3>
    <h3 v-else-if="type === 2">周热榜</h3>
    <h3 v-else-if="type === 3">总榜</h3>
    <!-- 商品区块 -->
    <div class="list">
      <GoodsItem v-for="item in list" :key="item.id" :goods="item" />
    </div>
  </div>
</template>

<script setup lang="ts">
import GoodsItem from '@/views/Category/components/goods-item.vue'
import { onMounted, ref } from 'vue-demi'
import { findGoodsHot } from '@/api/goods'
import { IGoodsItem } from '@/api/goods.types'
const props = defineProps({
  type: {
    type: Number,
    default: 1
  },
  goodsId: {
    type: String
  }
})

const list = ref<IGoodsItem[]>([])
onMounted(async () => {
  const { result } = await findGoodsHot({ id: props.goodsId, type: props.type })
  list.value = result
})
</script>

<style scoped lang="scss">

.goods-hot {
  h3 {
    height: 70px;
    background: $helpColor;
    color: #fff;
    font-size: 18px;
    line-height: 70px;
    padding-left: 25px;
    margin-bottom: 10px;
    font-weight: normal;
  }
  .list {
    background-color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}
</style>
